# -*- coding: utf_8 -*-
# @Create   : 2021/10/14 16:03
# @Author   : yyh
# @Remark   : ups 视图

from mxsoftpy import View

from index import _

from server.common.IOTManager.UpsDevice.dev_select import UPSSelectServer, UPSListServer, UPSRetrieveServer, \
    UPSTrendServer
from utils.public.params_method import check_params


class UPSSelectView(View):
    def post(self):
        return _("查询成功"), UPSSelectServer().select(**self.request.POST)


class UPSListView(View):
    @staticmethod
    def post():
        return _("查询成功"), UPSListServer().list()


class UPSRetrieveView(View):

    def post(self):
        check_params(self.request.POST, ["ups_code"])
        return _("查询成功"), UPSRetrieveServer().retrieve(self.request.POST["ups_code"])


class UPSTrendView(View):

    def post(self):
        check_params(self.request.POST, ["ups_code"])
        return _("查询成功"), UPSTrendServer().list(**self.request.POST)
